package br.com.klis.batendoumabola.client.view;

import br.com.klis.batendoumabola.client.presenter.PeladasPresenter;
import br.com.klis.batendoumabola.client.widgets.ContentVerticalPanel;
import br.com.klis.batendoumabola.client.widgets.EastVerticalPanel;
import br.com.klis.batendoumabola.client.widgets.FooterHorizontalPanel;
import br.com.klis.batendoumabola.client.widgets.HeaderHorizontalPanel;
import br.com.klis.batendoumabola.client.widgets.MenuVerticalPanel;
import br.com.klis.batendoumabola.shared.LoginInfo;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.Widget;

public class PeladasView extends Composite implements PeladasPresenter.Display {
	private ContentVerticalPanel contentPanel;
	private MenuVerticalPanel menuPanel;
	private HeaderHorizontalPanel headerPanel;
	private EastVerticalPanel eastPanel;
	private FooterHorizontalPanel footerPanel;

	public PeladasView(LoginInfo loginInfo) {
		GWT.log("init PeladasView...");
		DockPanel mainDockPanel = new DockPanel();
		mainDockPanel.setHorizontalAlignment(DockPanel.ALIGN_LEFT);
		mainDockPanel.setVerticalAlignment(DockPanel.ALIGN_TOP);
		mainDockPanel.setSize("100%", "100%");
		mainDockPanel.setSpacing(5);

		headerPanel = new HeaderHorizontalPanel();
		eastPanel = new EastVerticalPanel();
		footerPanel = new FooterHorizontalPanel();

		/*Label spaceHeaderLabel = new Label(" ");
		spaceHeaderLabel.setStyleName("titulo");
		HorizontalPanel spaceHeaderHorizontalPanel = new HorizontalPanel();
		spaceHeaderHorizontalPanel.setSize("100%", "100%");
		spaceHeaderHorizontalPanel.add(spaceHeaderLabel);*/

		contentPanel = new ContentVerticalPanel(loginInfo);
		menuPanel = new MenuVerticalPanel(loginInfo);

		//mainDockPanel.setBorderWidth(1);
		mainDockPanel.add(headerPanel, DockPanel.NORTH);
		mainDockPanel.add(footerPanel, DockPanel.SOUTH);
		mainDockPanel.add(menuPanel, DockPanel.WEST);
		mainDockPanel.add(eastPanel, DockPanel.EAST);
		mainDockPanel.add(contentPanel, DockPanel.CENTER);

		mainDockPanel.setCellWidth(menuPanel, "20%");
		mainDockPanel.setCellWidth(eastPanel, "20%");
		mainDockPanel.setCellWidth(footerPanel, "100%");
		//mainDockPanel.setCellHorizontalAlignment(contentPanel,DockPanel.ALIGN_CENTER);

		initWidget(mainDockPanel);
	}

	public HasClickHandlers getList() {
		return contentPanel.getContactsTable();
	}

	public Widget asWidget() {
		return this;
	}

	@Override
	public ContentVerticalPanel getContentPanel() {
		return contentPanel;
	}

	@Override
	public MenuVerticalPanel getMenuPanel() {
		return menuPanel;
	}

	@Override
	public FooterHorizontalPanel getFooterPanel() {
		return footerPanel;
	}

	@Override
	public EastVerticalPanel getEastPanel() {
		return eastPanel;
	}

	@Override
	public HasClickHandlers getSignIn() {
		return menuPanel.getSignInLink();
	}

	@Override
	public HasClickHandlers getSignOut() {
		return menuPanel.getSignOutLink();
	}

}
